package com.ruoyi.web.controller.saas;

import com.bonuo.saas.domain.IntellectualProperty;
import com.bonuo.saas.domain.IntellectualPropertyFile;
import com.bonuo.saas.service.IntellectualPropertyFileService;
import com.bonuo.saas.service.IntellectualPropertyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/saas/intellectualPropertyFile")
@Api(tags = "知识产权附件管理")
public class IntellectualPropertyFileController extends BaseController {

    @Autowired
    private IntellectualPropertyFileService intellectualPropertyFileService;

    @ApiOperation(value = "查询知识产权附件信息",httpMethod = "GET")
    @GetMapping("/list")
    public AjaxResult list(IntellectualPropertyFile intellectualPropertyFile){
        List<IntellectualPropertyFile> intellectualPropertyFileList = intellectualPropertyFileService.selectIntellectualPropertyFileList(intellectualPropertyFile);
        return success(intellectualPropertyFileList);
    }

    @ApiOperation(value = "添加知识产权附件信息",httpMethod = "POST")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody IntellectualPropertyFile intellectualPropertyFile){
        int result = intellectualPropertyFileService.insertIntellectualPropertyFile(intellectualPropertyFile);
        return toAjax(result);
    }

    @ApiOperation(value = "修改知识产权附件信息",httpMethod = "PUT")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody IntellectualPropertyFile intellectualPropertyFile){
        int result = intellectualPropertyFileService.updateIntellectualPropertyFile(intellectualPropertyFile);
        return toAjax(result);
    }

    @ApiOperation(value = "删除知识产权附件信息",httpMethod = "DELETE")
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Integer id){
        int result = intellectualPropertyFileService.deleteIntellectualPropertyFileById(id);
        return toAjax(result);
    }

}
